﻿using Domain.Flow;
using MediatR;
using U.B.ErrorCode;
using U.B.ReadApi.Command.Raddit.BW;
using U.B.Repistory;

namespace U.B.ReadApi.CommandHander.Raddit.BWHA
{
    public class GetKillCommandHander : IRequestHandler<GetKillCommand, ApiResult<Kill>>
    {
        public readonly IRepistory<Kill> _killRepistory;

        public GetKillCommandHander(IRepistory<Kill> killRepistory)
        {
            _killRepistory = killRepistory;
        }
        /// <summary>
        /// 屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<ApiResult<Kill>> Handle(GetKillCommand request, CancellationToken cancellationToken)
        {
            ApiResult <Kill> apiResult= new ApiResult<Kill>();
            var result = _killRepistory.GetAll().FirstOrDefault(x => x.BatchId == request.BatchId);
            apiResult.code = Renum.显示成功;
            apiResult.Data = result;
            apiResult.Message=Renum.显示成功.ToString();
            return Task.FromResult(apiResult);
        }
    }
}
